package com.ljcalc.business.components.requests;

/**
 * This is comment
 * SSL stands for svenska spel lotto
 * @author SELuoc
 *
 */
public class SSLHistoryResultRequest extends HistoryResultRequest {

//	http://svenskaspel.se/p4.aspx?pageid=16&selectWeekYear=2011&selectWeekWeek=29 lordag
//	http://svenskaspel.se/p4.aspx?pageid=15&selectWeekYear=2011&selectWeekWeek=29 onsdag
	
	protected static String CHANGE_STRING = "CHANGE";
	protected String SV_SP_RESULT = "http://svenskaspel.se/p4.aspx?pageid="+CHANGE_STRING+"&selectWeekYear="+CHANGE_STRING+"&selectWeekWeek="+CHANGE_STRING;

	public static int LORDAG_TYPE=15;
	public static int ONSDAG_TYPE=16;


	
	public SSLHistoryResultRequest(String url) {
		super(url);
		// TODO Auto-generated constructor stub
	}
	
	/*
	 * int type, lordag or onsdag, lordag=16, onsdag=15
	 * For svenska spel, every week is a round, it has two days, Wednesday and Saturday, each day is a type.
	 */
	public SSLHistoryResultRequest(int type, int year, int week){
		super(type,year,week);
	}
	
	public String getURLStr(){
		SV_SP_RESULT = SV_SP_RESULT.replaceFirst(CHANGE_STRING, new Integer(type).toString());
		SV_SP_RESULT = SV_SP_RESULT.replaceFirst(CHANGE_STRING, new Integer(year).toString());
		SV_SP_RESULT = SV_SP_RESULT.replaceFirst(CHANGE_STRING, new Integer(round).toString());			
		url = SV_SP_RESULT;
		return url;
	}
	
	public int getType() {
		return type;
	}

	public int getYear() {
		return year;
	}

	public int getRound() {
		return round;
	}
	
	public int compareTo(HistoryResultRequest hrr) {
		int rufresult = super.compareTo(hrr);
		if(hrr instanceof SSLHistoryResultRequest){
			
			if(rufresult==0){
				rufresult = hrr.getType()-this.getType();
			}
		}else{
			new Exception().printStackTrace();
		}
		return rufresult;
	}

}
